package com.sumi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.sumi.common.annotation.Log;
import com.sumi.common.core.controller.BaseController;
import com.sumi.common.core.domain.AjaxResult;
import com.sumi.common.enums.BusinessType;
import com.sumi.system.domain.SysSeller;
import com.sumi.system.service.ISysSellerService;
import com.sumi.common.utils.poi.ExcelUtil;
import com.sumi.common.core.page.TableDataInfo;

/**
 * 公司列表Controller
 * 
 * @author fgf67@163.com
 * @date 2024-06-26
 */
@RestController
@RequestMapping("/system/seller")
public class SysSellerController extends BaseController
{
    @Autowired
    private ISysSellerService sysSellerService;

    /**
     * 查询公司列表列表
     */
    @PreAuthorize("@ss.hasPermi('system:seller:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysSeller sysSeller)
    {
        startPage();
        List<SysSeller> list = sysSellerService.selectSysSellerList(sysSeller);
        return getDataTable(list);
    }

    /**
     * 导出公司列表列表
     */
    @PreAuthorize("@ss.hasPermi('system:seller:export')")
    @Log(title = "公司列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysSeller sysSeller)
    {
        List<SysSeller> list = sysSellerService.selectSysSellerList(sysSeller);
        ExcelUtil<SysSeller> util = new ExcelUtil<SysSeller>(SysSeller.class);
        util.exportExcel(response, list, "公司列表数据");
    }

    /**
     * 获取公司列表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:seller:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysSellerService.selectSysSellerById(id));
    }

    /**
     * 新增公司列表
     */
    @PreAuthorize("@ss.hasPermi('system:seller:add')")
    @Log(title = "公司列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysSeller sysSeller)
    {
        return toAjax(sysSellerService.insertSysSeller(sysSeller));
    }

    /**
     * 修改公司列表
     */
    @PreAuthorize("@ss.hasPermi('system:seller:edit')")
    @Log(title = "公司列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysSeller sysSeller)
    {
        return toAjax(sysSellerService.updateSysSeller(sysSeller));
    }

    /**
     * 删除公司列表
     */
    @PreAuthorize("@ss.hasPermi('system:seller:remove')")
    @Log(title = "公司列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysSellerService.deleteSysSellerByIds(ids));
    }
}
